#!/usr/bin/php
<?php

if ($argc < 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
    ?>

    This is a command line PHP script with one option.

      Usage:
      <?php echo $argv[0]; ?> <option>

      <option> can be some word you would like
      to print out. With the --help, -help, -h,
      or -? options, you can get this help.

<?php
} else {

    $quality = 80;

    $file = $argv[1];
    $finalWidth = isset($argv[2]) ? $argv[2] : 300;
    $pathinfo = pathinfo($file);
    $newfile = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . ".edit." . $pathinfo['extension'];

    $output = shell_exec("convert $file -resize $finalWidth -quality $quality $newfile");
    
}
?>

All done.

